package com.wn.controller;

import com.wn.entity.*;
import com.wn.service.CateringService;
import com.wn.service.HotelinfoService;
import com.wn.service.ScenicService;
import com.wn.service.SurroundingsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * (Surroundings)表控制层
 *
 * @author makejava
 * @since 2020-10-26 09:41:08
 */
@RestController
@RequestMapping("surroundings")
public class SurroundingsController {
    /**
     * 服务对象
     */
    @Resource
    private SurroundingsService surroundingsService;

    @Autowired
    private ScenicService scenicService;
    @Autowired
    private HotelinfoService hotelinfoService;
    @Autowired
    private CateringService cateringService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public Surroundings selectOne(String id) {
        return this.surroundingsService.queryById(id);
    }



//    @GetMapping("selAll/{longitude}/{latitude}")
//    public Map<String, Object> selAll(@PathVariable("longitude") double longitude,
//                                      @PathVariable("latitude") double latitude){

//        @PostMapping("selAll")
//        public Map<String, Object> selAll(@RequestBody Hotelinfo hotelinfo){
//
//        List<Scenic> sc= scenicService.selScenic(hotelinfo.getLongitude(),hotelinfo.getLatitude());
//
//
//        List<Hotelinfo> ho = hotelinfoService.selHotel(hotelinfo.getLongitude(),hotelinfo.getLatitude());
//
//
//        List<Catering> cate = cateringService.selCatering(hotelinfo.getLongitude(),hotelinfo.getLatitude());
//
//        Map<String, Object> map = new HashMap<>();
//        map.put("scenic",sc);
//        map.put("hotel",ho);
//        map.put("catering",cate);
//
//        return map;
//    }
    //根据经纬度查询周边信息
@PostMapping("selAll")
public Map<String,Object> selAll(@RequestBody VoAll vo){


    List<Scenic> sc= scenicService.selScenic(vo.getLongitude(),vo.getLatitude());


    List<Hotelinfo> ho = hotelinfoService.selHotel(vo.getLongitude(),vo.getLatitude());


    List<Catering> cate = cateringService.selcatering(vo.getLongitude(),vo.getLatitude());

    Map<String, Object> map = new HashMap<>();
    map.put("scenic",sc);
    map.put("hotel",ho);
    map.put("catering",cate);

    return map;
}
}
